package com.kude.manager;

import java.util.List;

import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Order;

import com.kude.manager.support.IQuerySupport;


public interface IManager<T> {
	/**
	 * 返回记录数
	 * 
	 * @param querySupport
	 *            查询条件
	 * @return
	 */
	public int getTotal(IQuerySupport querySupport) throws OperException;

	/**
	 * 返回总记录数
	 * 
	 * @return
	 */
	public int getTotal() throws OperException;

	/**
	 * 添加记录
	 * 
	 * @param obj
	 */
	public void add(T obj) throws OperException;

	/**
	 * 删除记录
	 * 
	 * @param obj
	 */
	public void delete(T obj) throws OperException;
	
	/**
	 * 删除记录
	 * @param id 记录ID
	 */
	public void delete(int id) throws OperException;

	/**
	 * 查询记录
	 * 
	 * @param id
	 *            记录ID
	 * @return
	 */
	public T get(int id) throws OperException;
	
	/**
	 * 
	 * @param criterion
	 * @return
	 * @throws OperException
	 */
	public List<T> find(Criterion... criterion) throws OperException;
	
	/**
	 * 查询记录
	 * 
	 * @param offset 起始数
	 * @param limit  返回记录最大数目
	 * @return
	 * @throws OperException
	 */
	public List<T> find(int offset, int limit) throws OperException;
	
	/**
	 * 
	 * @param order
	 * @param offset
	 * @param limit
	 * @return
	 * @throws OperException
	 */
	public List<T> find(Order order, int offset, int limit) throws OperException;
	
	/**
	 * 
	 * @param offset
	 * @param limit
	 * @param criterion
	 * @return
	 * @throws OperException
	 */
	public List<T> find(int offset, int limit, Criterion... criterion) throws OperException;

	/**
	 * 
	 * @param order
	 * @param offset
	 * @param limit
	 * @param criterion
	 * @return
	 * @throws OperException
	 */
	public List<T> find(Order order, int offset, int limit, Criterion... criterion) throws OperException;


	/**
	 * 更新记录
	 * 
	 * @param obj
	 * @throws OperException
	 */
	public void update(T obj) throws OperException;
	
	/**
	 * 判断记录是否存在
	 * @param obj
	 * @return
	 */
	public boolean isExist(T obj) throws OperException;
		
}